import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
//默认样式reset
import '@/assets/css/reset.css'
import '@/assets/css/icon.css'
import rem from '@/rem'
import * as ajax from '@/request'
// vant
import Vant from 'vant'
import 'vant/lib/index.css'
Vue.use(Vant)
Vue.prototype.$http = ajax
Vue.config.productionTip = false

router.beforeEach((to, from, next) => {
  if (to.meta.isAuthRequired === true) {
    if (store.getters.isLogin === true) {
      next()
    } else {
      next({
        name: 'lwlogin',
        params: {
          from: to.path
        }
      })
    }
  }
  next()
})

new Vue({
  router,
  store,
  rem,
  render: h => h(App)
}).$mount('#app')
